package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectTest {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<Student> clazz = Student.class;

        // 获取public修饰的构造方法
        Constructor<Student> constructor1 = clazz.getConstructor(String.class, int.class);

        Student student1 = constructor1.newInstance("Tom", 18);

        System.out.println(student1.getName() + " " + student1.getAge());
    }
}
